﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using WindowsForms.service;
using Model;
using WindowsForms.Class;

namespace WindowsForms
{
    public partial class BookingsProcess : DevExpress.XtraEditors.XtraForm
    {
        Service1 iQuery;
        private List<Tables> lstTablesSource = null;

        public BookingsProcess()
        {
            iQuery = new Service1();
            ConvertToList convert = new ConvertToList();
            lstTablesSource = convert.ConvertTolistTables(iQuery.SelectTablesAll().Tables[0]);

            InitializeComponent();

            cbTables.Properties.DataSource = lstTablesSource;
        }

        public Tables Table
        {
            get
            {
                return lstTablesSource.Find(delegate(Tables id)
                {
                    return id.TableID == (int)cbTables.EditValue;
                });
            }
        }

        public int TableId
        {
            get
            {
                return (int)cbTables.EditValue;
            }
            set
            {
                cbTables.EditValue = value;
            }
        }

        public DateTime BookingDate
        {
            get
            {
                return DateTime.Parse(txtBookingDate.Text);
            }
            set
            {
                txtBookingDate.Text = value.ToString();
            }
        }

        private void BookingsProcess_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = !dxValidationProviderTable.Validate() && DialogResult == DialogResult.OK;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {

        }
    }
}